package com.lcf.app.oauth2.controller;

import com.lcf.app.oauth2.entity.User;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    /**
     * 获取当前用户
     * @param authorization
     * @return
     */
    @GetMapping("get")
    public User getCurrentUser(Authentication authorization) {
        return (User) authorization.getPrincipal();
    }

}
